package cn.yh.kettle_service;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootVersion;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.SpringVersion;
import org.springframework.scheduling.annotation.EnableAsync;

import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;

@SpringBootApplication
@EnableAsync
public class KettleServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(KettleServiceApplication.class, args);
        System.out.println("kettle启动成功");
        // 获取系统性能信息
        printSystemPerformanceInfo();
    }



    // 获取系统性能信息
    private static void printSystemPerformanceInfo() {
        // 获取操作系统信息
        OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean();
        // CPU 数量
        int availableProcessors = osBean.getAvailableProcessors();
        // JVM 最大内存（单位：字节）
        long maxMemory = Runtime.getRuntime().maxMemory();
        // JVM 已用内存（单位：字节）
        long usedMemory = Runtime.getRuntime().totalMemory();
        // JVM 空闲内存（单位：字节）
        long freeMemory = Runtime.getRuntime().freeMemory();
        // 打印性能信息
        System.out.println("Spring Boot Version: " + SpringBootVersion.getVersion());
        System.out.println("Spring Version: " + SpringVersion.getVersion());
        System.out.println("操作系统: " + osBean.getName() + " " + osBean.getVersion());
        System.out.println("系统架构: " + osBean.getArch());
        System.out.println("CPU 数量: " + availableProcessors);
        System.out.println("JVM 最大内存: " + maxMemory / (1024 * 1024) + " MB");
        System.out.println("JVM 已用内存: " + usedMemory / (1024 * 1024) + " MB");
        System.out.println("JVM 空闲内存: " + freeMemory / (1024 * 1024) + " MB");
    }
}
